<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增每日出勤情况登记')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: jasny-bootstrap-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-kqworks-add">
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">时间：</label>
                <div class="col-sm-4">
                    <div class="input-group date">
                        <input name="rq" th:value="${rq}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
                <label class="col-sm-2 control-label is-required">班组：</label>
                <div class="col-sm-4">
                    <select name="banz" class="form-control" required th:with="type=${@dict.getType('gcgl_kqbanz')}">
		                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"></option>
		            </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">带班：</label>
                <div class="col-sm-4">
                    <input name="daib" class="form-control" type="text" required>
                </div>
                <label class="col-sm-2 control-label is-required">编码：</label>
                <div class="col-sm-4">
                    <select name="code" class="form-control" required>
		                <option th:each="dict : ${projectlis}" th:text="${dict.name}" th:value="${dict.orderNo}"></option>
		            </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">工程名称：</label>
                <div class="col-sm-4">
                    <input name="projectName" class="form-control" type="text" required>
                </div>
                <label class="col-sm-2 control-label is-required">假/车：</label>
                <div class="col-sm-4">
                    <select name="jc" class="form-control" required th:with="type=${@dict.getType('gcgl_jc')}">
		                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"></option>
		            </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">出工人员：</label>
                <div class="col-sm-10">
	                <label th:each="user:${sysUserlis}" class="check-box">
						<input name="peopleIds" type="checkbox" th:value="${user.userId}" th:text="${user.userName}" >
					</label>
                </div>
            </div>
            <div class="form-group">   
                <label class="col-sm-2 control-label is-required">出工情况：</label>
                <div class="col-sm-4 input-group">
                    <input name="descs" class="form-control" id="suggest-demo-1" type="text" required>
                    <div class="input-group-btn">
                        <button type="button" class="btn btn-white dropdown-toggle" style="height: 31px" data-toggle="dropdown">
                            <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu dropdown-menu-right" role="menu">
                        </ul>
                    </div>
                </div>
            </div>
            <div class="form-group">
           		<label class="col-sm-2 control-label is-required">资料文件：</label>
               	<div class="col-sm-10 fileinput fileinput-new" data-provides="fileinput">
                   <span class="btn btn-white btn-file">
                   	<span class="fileinput-new">选择文件</span>
                   	<span class="fileinput-exists">更改</span>
                   	<input type="file" name="zilwjfile" id="zilwjfile" required>
                   </span>
                   <span class="fileinput-filename"></span>
                   <a href="#" class="close fileinput-exists" data-dismiss="fileinput" style="float: none">&times;</a>
            	</div>
            </div>
        </form>
    </div>
    
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
    
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: jasny-bootstrap-js" />
    <th:block th:include="include :: bootstrap-suggest-js" />
    <th:block th:include="include :: bootstrap-typeahead-js" />
    <script th:inline="javascript">
        var prefix = ctx + "gcgl/kqworks"
        $("#form-kqworks-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
			if ($.validate.form()) {
            	
            	var form = document.getElementById("form-kqworks-add");
                var file = new FormData(form);
                $.ajax({
                    url: "/gcgl/kqworks/add",
                    type: "POST",
                    processData:false,
                    contentType:false,
                    //重要部分，data的传的是整个表单，不用大括号包裹；不用自定义变量名
                    data:file,
                    success: function (date) {
                    	$.modal.close();
                    	refreshTab();
                    },
                    error: function (date) {
                    	$.modal.close();
                    	refreshTab();
                    }
                })
            	
                //$.operate.saveTab(prefix + "/add", $('#form-kqworks-add').serialize());
            }
        }

        $("input[name='rq']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        
        var testBsSuggest = $("#suggest-demo-1").bsSuggest({
	        url: ctx + "gcgl/kqworks/cgqk",
	        idField: "dictValue",
	        keyField: "dictValue"
	    }).on('onDataRequestSuccess', function (e, result) {
	        console.log('onDataRequestSuccess: ', result);
	    }).on('onSetSelectValue', function (e, keyword) {
	        console.log('onSetSelectValue: ', keyword);
	    }).on('onUnsetSelectValue', function (e) {
	        console.log("onUnsetSelectValue");
	    });

    </script>
</body>
</html>